/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ronin.util;
import java.util.TreeMap;
import ronin.actor2d.Actor2D;
/**
 *
 * @author yardigan
 */
public class EntityManager {

    static EntityManager em = new EntityManager();
    
    int uidCount;
    
    TreeMap entityMap;
    
    private EntityManager(){
        entityMap = new TreeMap();
        uidCount = 0; 
    }
    
    /**
     * Returns an instance of the entity manager
     */
    public static EntityManager getInstance()
    {
        if(em == null) em = new EntityManager();
        
        return em;
    }
    
    /**
     * Sets bot uid and adds it to the entity map
     * @param bot
     * @return
     */
    public boolean register(Actor2D bot) {
        if(entityMap.containsValue(bot))return false;
        bot.setID(uidCount);
        entityMap.put(uidCount, bot);
        uidCount++;
        return true;
    }
    
    public Actor2D getByID(int id) {
        return (Actor2D) entityMap.get(id);
    }
    
    public void removeEntity(int entityID) {
        
    }
}
